public class float[][]
extends Object
GDK enhancements for float[][].
| Type Params | Return Type | Name and description |
|---|---|---|
|
public float[] |
column(int col)Select a column from a 2D array. |
|
public float |
eachColumn(Closure<?> closure)Process the columns of the array. |
|
public List<Float> |
flatten()Flattens a 2D array into a new collection. |
|
public float |
transpose()A transpose method for 2D float arrays. |
|
public Iterator<float[]> |
transposing()An iterator of the columns of the array. |
| Methods inherited from class | Name |
|---|---|
class Object |
addShutdownHook, any, any, asBoolean, asType, collect, collect, collect, dump, each, eachMatch, eachMatch, eachWithIndex, every, every, find, find, findAll, findAll, findIndexOf, findIndexOf, findIndexValues, findIndexValues, findLastIndexOf, findLastIndexOf, findResult, findResult, findResult, findResult, getAt, getMetaClass, getMetaPropertyValues, getProperties, grep, grep, hasProperty, identity, inject, inject, inspect, invokeMethod, is, isCase, isNotCase, iterator, metaClass, print, print, printf, printf, println, println, println, putAt, respondsTo, respondsTo, setMetaClass, sleep, sleep, split, sprintf, sprintf, stream, tap, toString, use, use, use, with, with, withCloseable, withCloseable, withMethodClosure, withStream, withStream, withTraits |
Select a column from a 2D array.
float[][] nums = [[1.0f, 2.0f], [10.0f, 20.0f]]
assert nums.column(0) == [1.0f, 10.0f] as float[]
assert nums.column(1) == [2.0f, 20.0f] as float[]
Process the columns of the array.
double[][] nums = [[1.0f, 2.0f], [10.0f, 20.0f]]
nums.eachColumn {
assert it[0] * 10.0f == it[1]
}
closure - the closure applied on each array columnFlattens a 2D array into a new collection. The items are copied row by row.
Example usage:
float[][] array = [[0.0f, 1.0f], [2.0f, 3.0f]]
assert array.flatten() == [0.0f, 1.0f, 2.0f, 3.0f]
A transpose method for 2D float arrays.
Example usage:
float[][] floats = [[1.0f, 10.0f], [2.0f, 20.0f]]
float[][] expected = [[1.0f, 2.0f], [10.0f, 20.0f]]
def result = floats.transpose()
assert result == expected
assert floats.class.componentType == result.class.componentType
An iterator of the columns of the array.
float[][] nums = [[1.0f, 2.0f], [10.0f, 20.0f]]
assert nums.transpose() == nums.transposing().toList()